package mya_dc.master_server.threads;

import mya_dc.master_server.MasterServer;

/**
 * A thread that saves the current data in the master-server
 * and invokes the verifyDataBase() method on the parent
 * in order to verify that DB has not been corrupted
 */
public class SaveDataThread extends Thread
{
	public static long delayBetweenSavesMiliSeconds = 5000;
	
	public SaveDataThread(MasterServer parent)
	{
		m_Parent = parent;
	}
	@Override
	public void run()
	{
		while(true)
		{
			m_Parent.saveData();
			m_Parent.verifyDataBase();
			try { Thread.sleep(delayBetweenSavesMiliSeconds); }
			catch (InterruptedException e) { }
		}

	}

	private MasterServer m_Parent;
}
